package com.shujia.hbase;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class Demo8PhoenixJdbc {
    public static void main(String[] args) throws Exception {

        //创建连接
        Connection connection = DriverManager.getConnection("jdbc:phoenix:master,node1,node2:2181");

        //构建执行器
        PreparedStatement stat = connection.prepareStatement("select mdn,x,y,county from dianxin where x=? and y =?");

        stat.setDouble(1, 117.288);
        stat.setDouble(2, 31.822);


        //执行查询
        ResultSet resultSet = stat.executeQuery();


        while (resultSet.next()) {
            String mdn = resultSet.getString("mdn");
            double x = resultSet.getDouble("x");
            double y = resultSet.getDouble("y");

            String county = resultSet.getString("county");

            System.out.println(mdn + "\t" + x + "\t" + y + "\t" + county);
        }


        connection.close();

    }
}
